package com.stox.ui.javafx.core.widget.wrapper;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.OrderComparator;
import org.springframework.stereotype.Component;

@Component
public class MenuBar extends javafx.scene.control.MenuBar  implements InitializingBean{

	@Autowired
	private ApplicationContext applicationContext;
	
	
	public MenuBar() {
		super();
	}
	
	@Override
	public void afterPropertiesSet() throws Exception {
		List<Menu> menus = new ArrayList<Menu>(applicationContext.getBeansOfType(Menu.class).values());
		OrderComparator.sort(menus);
		getMenus().addAll(menus);
	}

}
